# Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.

# CMake lowest version requirement
cmake_minimum_required(VERSION 3.5.0)

# project information
project(FairMOT)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

# Compile options
add_compile_options(-std=c++11 -fPIE -fstack-protector-all -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -s -pie -Wall)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0 -Dgoogle=mindxsdk_private)

set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(MX_SDK_HOME $ENV{MX_SDK_HOME})#/home/liuyipeng2/NewSDKRC3/mxVision-3.0.RC3/
set(FFMPEG_PATH /usr/local/ffmpeg)
# SET(CMAKE_BUILD_TYPE "Debug")
# SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
# SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

# Header path
include_directories(
    ${MX_SDK_HOME}/include
    ${MX_SDK_HOME}/opensource/include
    ${MX_SDK_HOME}/opensource/include/opencv4
    /usr/local/Ascend/ascend-toolkit/latest/runtime/include
    ${FFMPEG_PATH}/include
    /home/HwHiAiUser/Ascend/ascend-toolkit/latest/include/

    ${MX_SDK_HOME}/opensource/include/gstreamer-1.0/
    ${MX_SDK_HOME}/opensource/include/glib-2.0
    ${MX_SDK_HOME}/opensource/lib/glib-2.0/include/
    ./
)

# add host lib path
link_directories(

    ${MX_SDK_HOME}/lib
    ${MX_SDK_HOME}/opensource/lib
    ${MX_SDK_HOME}/lib/modelpostprocessors
    /usr/local/Ascend/ascend-toolkit/latest/acllib/lib64
    /usr/local/Ascend/driver/lib64/
    /usr/lib/aarch64-linux-gnu/
    ${FFMPEG_PATH}/lib
    
    ${MX_SDK_HOME}/opensource/lib64/
    ${MX_SDK_HOME}/opensource/lib/gstreamer-1.0/
    ${MX_SDK_HOME}/opensource/lib/glib-2.0/
)

aux_source_directory(. sourceList)

add_executable(main ${sourceList})

target_link_libraries(main
    avcodec
    avdevice
    avfilter
    avformat
    avcodec
    avutil
    swscale
    swresample
    glog
    mxbase
    cpprest
    opencv_world
    boost_filesystem
    -lpthread
    -lz
    -llzma
    -lbz2
    ascendcl
    acl_dvpp_mpi
)
install(TARGETS main DESTINATION CMAKE_RUNTIME_OUTPUT_DIRECTORY)